home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Languguage OS 2
/
Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO
/
language
/
embedded
/
mcu
/
dtmf.arc
/
MAKESINE.C
< prev
next >
Wrap
C/C++ Source or Header
|
1989-12-17
|
1KB
|
47 lines
/* makesine.c - make sine wave table for assembly language */
#include <stdio.h>
#include <math.h>
#define MAXSINE 56
#define OFFSET 0
#define COUNT 256
#define LINECNT 8
#define PI 3.14159
main (argc,argv)
int argc;
char **argv;
{
int i,linect;
double maxsine, offset, count;
maxsine = MAXSINE;
offset = OFFSET;
count = COUNT;
if (argc > 4) usage (argv [0]);
if (argc > 1) maxsine = atoi (argv [1]);
if (argc > 2) count = atoi (argv [2]);
if (argc == 4) offset = atoi (argv [3]);
if (maxsine == 0 || count == 0) usage (argv [0]);
printf ("sine");
for (i = 0; i < count;)
{
printf ("\tfcb\t");
for (linect = 0;(linect < LINECNT) && (i != count); i++,linect++)
printf ("%1.0f%s",
offset + maxsine * sin (2 * PI * ((double) i / count)),
(linect == LINECNT-1) || (i == count - 1) ? "" : ",");
printf ("\n");
}
exit (0);
}
usage (name)
char *name;
{
fprintf (stderr, "usage: %s [maxsine [count [offset]]]\n", name);
exit (1);
}